package com.smartrobot.smartrobot.activity;

import android.test.ActivityInstrumentationTestCase2;

import com.robotium.solo.Solo;


public class ScheduleActivityTest extends ActivityInstrumentationTestCase2<ScheduleActivity> {

    private Solo solo;

    public ScheduleActivityTest() {
        super(ScheduleActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        solo = new Solo(getInstrumentation(), getActivity());

    }

    @Override
    public void tearDown() throws Exception {

        solo.finishOpenedActivities();

    }

    /**
     * 测试ui界面 是否具备以下元素
     * @throws Exception
     */
    public void testUI()throws Exception{

        //预期结果
        boolean expected = true;
        //实际的结果
        boolean result1 = solo.searchText("电话");
        boolean result2 =  solo.searchText("我的日程");

        assertEquals(expected,result1);
        assertEquals(expected,result2);


    }

    public void testAddDetail(){

        boolean expected = true;

        solo.clickOnView(getActivity().add);
        //没有输入事件，添加不成功

        solo.clickOnText("确定");
        boolean result1 = solo.searchText("日程不能为空");

        //输入日期是否添加成功
        solo.enterText(2,"测试日程");
        solo.clickOnText("确定");
//        solo.enterText(0,"04");
//        solo.enterText(1,"44");
        boolean result2 = solo.searchText("测试日程");
//        boolean result3 = solo.searchText("0458");

        assertEquals(expected,result1);
        assertEquals(expected,result2);

    }

}